<?php

namespace App\Admin\Models;

use App\Admin\Traits\staticMaps;
use Illuminate\Database\Eloquent\Model;

class Shop extends Model
{
    use staticMaps;
    
    protected $appends = ['on_time_start', 'on_time_end'];
    
    public function __construct()
    {
        parent::__construct();
    
        $this->setTable('shops');
    }
    
    public function city()
    {
        return $this->belongsTo(City::class);
    }
    
    public function getOnTimeStartAttribute()
    {
        return explode('-', $this->attributes['on_time'])[0] ?? '';
    }
    
    public function getOnTimeEndAttribute()
    {
        return explode('-', $this->attributes['on_time'])[1] ?? '';
    }
}
